package runFromHere;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;

import boundarys.AbstractGUI;
import ccrm.BoundryControl;
import ccrm.ClientMain;
import entitys.Session;
import enums.Result;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class ClientGUI extends AbstractGUI {

	private JFrame frmCcrmclient;
	private JTextField ipTextField;
	private int index;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				BoundryControl.GUIArr.add(new AbstractGUI() {
					
					@Override
					public void getReply(Object r) {
						// TODO Auto-generated method stub
						
					}
				});
				try {
					ClientGUI window = new ClientGUI();
					window.frmCcrmclient.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public ClientGUI() {
		initialize();
		initGUI(frmCcrmclient);
		frmCcrmclient.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmCcrmclient = new JFrame();
		frmCcrmclient.setResizable(false);
		frmCcrmclient.setTitle("Connecting to Server");
		frmCcrmclient.setBounds(100, 100, 397, 155);
		frmCcrmclient.getContentPane().setLayout(null);
		
		ipTextField = new JTextField();
		ipTextField.setText("localhost");
		ipTextField.setBounds(77, 53, 143, 20);
		frmCcrmclient.getContentPane().add(ipTextField);
		ipTextField.setColumns(10);
		
		JButton btnNewButton = new JButton("Connect");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				ClientMain.connectClient(ipTextField.getText());
				Session.setIp(ipTextField.getText());
				frmCcrmclient.dispose();
			}
		});
		btnNewButton.setBounds(244, 47, 111, 33);
		frmCcrmclient.getContentPane().add(btnNewButton);
		
		JLabel lblIp = new JLabel("IP");
		lblIp.setBounds(39, 56, 46, 14);
		frmCcrmclient.getContentPane().add(lblIp);
	}

	@Override
	public void getReply(Object r) {
		// TODO Auto-generated method stub
		
	}


}
